Contents |
Different languages use different symbols for the concatenation operator. Most languages use the "+" symbol, though several deviate from this norm.
Operator | Languages |
---|---|
+ | ALGOL 68, BASIC, C++, C#, Pascal, Object Pascal, Eiffel, Go, JavaScript, Java, Python, Turing, Ruby, Windows PowerShell, Objective-C, F# |
++ | Haskell |
$+ | mIRC Scripting Language |
& | Ada, AppleScript, Curl, VHDL, Visual Basic, Excel |
. | Perl (before version 6), PHP, and Maple (up to version 5), Autohotkey |
~ | Perl 6 and D |
|| | Icon, Standard SQL, PL/I, Rexx, and Maple (from version 6) |
<> | Mathematica |
.. | Lua |
, | J programming language, Smalltalk |
^ | OCaml, Standard ML, F#, rc |
// | Fortran |
strcat
function must be used.[x y]
" to concatenate x and y.+
" sign but, this leads to ambiguity if a string representing a number and a number is added together.&
" and the function "=CONCATENATE(X,Y)
".This section compares styles for declaring a string literal.
Syntax | Language(s) |
---|---|
@"Hello, world!" | C#, F# |
"Hello, world!" | Java |
r"Hello, world!" | Python |
'Hello, world!' | Pascal, Object Pascal, PHP, Perl, Windows PowerShell |
<![CDATA[Hello, world!]]> | XML (CDATA section) |
`Hello, world!` | Go, Smalltalk |
Syntax | Language(s) |
---|---|
"Hello, $name!" | PHP, Perl, Windows PowerShell |
"Hello, #{name}!" | Ruby |
Syntax | Language(s) |
---|---|
"I said \"Hello, world!\"" | C, C++, C#, F#, Java, Ocaml, Python |
"I said `"Hello, world!`"" | Windows Powershell |
"I said ^"Hello, world!^"" | REBOL |
"I said, %"Hello, World!%"" | Eiffel |
Syntax | Language(s) |
---|---|
"I said ""Hello, world!""" | ALGOL 68, Excel, Visual Basic, COBOL |
'I said ''Hello, world!''' | rc |
Syntax | Language(s) |
---|---|
qq(I said "Hello, world!") | Perl |
%Q(I said "Hello, world!") %(I said "Hello, world!") |
Ruby |
{I said "Hello, world!"} | REBOL |
Syntax | Language(s) |
---|---|
<<EOF I have a lot of things to say and so little time to say them EOF |
Perl, PHP, Ruby |
@" I have a lot of things to say and so little time to say them "@ |
Windows Powershell |
"[ I have a lot of things to say and so little time to say them ]" |
Eiffel |
Syntax | Variant name | Language(s) |
---|---|---|
′I said ′′Hello, world!′′.′ | Double quoting | Smalltalk |
'I said ''Hello, world!''.' |
Double quoting | Pascal, Object Pascal, SQL standard |
"""Hello, world!""" | Triple quoting | Python |
13HHello, world! | Hollerith notation | Fortran 77 |
(indented with whitespace) | Indented with whitespace and newlines | YAML |